package com.autumn.spring.boot.context;

/**
 * 服务上下文持有人
 * 
 * @author 老码农
 *         <p>
 *         自动现服务上下文注入和清除
 *         </p>
 *         2017-12-29 17:28:49
 */
public class SrpingServiceContextHolder {

	private static final ThreadLocal<String> REQUEST_CONTEXT_SERVICE = new InheritableThreadLocal<>();

	/**
	 * 获取请求服务id
	 * 
	 * @return
	 */
	public static String getRequestServiceId() {
		return REQUEST_CONTEXT_SERVICE.get();
	}

	/**
	 * 移除请求服务Id
	 * 
	 * @return
	 */
	public static void removeRequestServiceId() {
		REQUEST_CONTEXT_SERVICE.remove();
	}

	/**
	 * 设置请求服务Id
	 * 
	 * @param serviceId
	 *            服务id
	 *
	 */
	public static void setRequestServiceId(String serviceId) {
		REQUEST_CONTEXT_SERVICE.set(serviceId);
	}
}
